package com.example.helloworld;

public class Employee {
    // private  私有的
    private String name;  // 名称
    private int age; // 年龄
    private String designation;  // 职业
    private double salary; // 工资
    // 构造器(与类同名)
    public Employee(String name){
        this.name = name;
    }
    // 设置age
    public void setAge(int age){
        this.age = age;
    }
    // 获取age
    public int getAge(){
        return age;
    }
    // 设置designation
    public void setDesignation(String designation){
        this.designation = designation;
    }
    // 获取designation
    public String getDesignation(){
        return designation;
    }
    // 设置salary
    public void setSalary(double salary){
        this.salary = salary;
    }
    // 获取salary
    public double getSalary(){
        return salary;
    }
    // 打印全部
    public void printEmployee(){
        System.out.println(this);
    }
    // 重写 toString 方法
    @Override
    public String toString() {
        return "名字: " + name + "\n" +
                "年龄: " + age + "\n" +
                "职位: " + designation + "\n" +
                "薪水: " + salary;
    }
}
